In [1]:
%matplotlib inline
import numpy
import matplotlib
from matplotlib.patches import Circle, Wedge, Polygon
from matplotlib.collections import PatchCollection
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import matplotlib.lines as mlines
import matplotlib.path as mpath
import numpy as np
import seaborn as sns
import networkx as nx
import pandas as pd
In [2]:
import SeaFallLogic
In [2]:
class Ship():
# Rules, pg 8, "Province Boards" also inlcude information about ships
def __init__(self):
self.damage = []
# hold, a list of objects with max length hold
self.hold = []
# upgrades, a list of upgrade objects of max length 2
self.upgrades = []
# values (explore, hold, raid, sail)
self._values = (1, 1, 1, 1)
# vmax is the maximum number values can reach for (explore, hold, raid,
# sail)
self._vmax = (5, 5, 5, 5)
@property
def values(self):
return self._values
@values.setter
def values(self, values):
if not isinstance(values, tuple):
err_str = ("Not a valid data type. The data type should be a tuple"
" of 4 length.")
raise ValueError(err_str)
elif len(values) != 4:
err_str = ("Not a valid data type. The data type should be a tuple"
" of 4 length.")
raise ValueError(err_str)
for val, vmax in zip(values, self.vmax):
if val > vmax:
raise ValueError("A ship value exceeds its max.")
self._values = values
@property
def vmax(self):
return self._vmax
@vmax.setter
def vmax(self, vmax_tuple):
if not isinstance(vmax_tuple, tuple):
err_str = ("Not a valid data type. The data type should be a tuple"
" of 4 length.")
raise ValueError(err_str)
elif len(vmax_tuple) != 4:
err_str = ("Not a valid data type. The data type should be a tuple"
" of 4 length.")
raise ValueError(err_str)
for val, vmax in zip((5, 5, 5, 5), vmax_tuple):
if val > vmax:
raise ValueError("The maximum ship values are never less than (5, 5, 5, 5).")
self._vmax = vmax
In [3]:
ship = Ship()
In [4]:
ship.values
Out[4]:
In [5]:
class Site():
def __init__(self, dangerous=False, defense=0):
# Rules, pg 10, "Dangerous Sites"
self.dangerous = dangerous
# Rules, pg 10, "Starting an Endeavor"
# Rules, pg 7, "Defense"
self.defense = defense
class IslandSiteMine(Site):
def __init__(self, dangerous=False, defense=0, gold=0):
super().__init__(dangerous=dangerous, defense=defense)
self.gold = gold
In [6]:
mine = IslandSiteMine()
In [7]:
mine.dangerous
Out[7]:
In [8]:
mine.defense
Out[8]:
In [9]:
mine2 = IslandSiteMine(dangerous=True, defense=10, gold=6)
In [10]:
mine2.gold
Out[10]:
In [11]:
class Goods():
valid_goods = {
"iron",
"linen",
"spice",
"wood"
}
def __init__(self):
pass
In [14]:
Goods.valid_goods
Out[14]:
In [20]:
"iron" in Goods.valid_goods
Out[20]:
In [22]:
In [ ]: